<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>margin</title>
</head>
<style>
    #main{
        width: 600px;
        margin: 0 auto;
    }
    div {
        border: red 1px solid;
    }
    #main-auto {
        max-width: 600px;
        margin: 0 auto;
    }
</style>
<body>
    <div id="main">
        设置宽度并且居中........................................mid....................................................................................mid
    </div>
    <hr> 
    <div id="main-auto">
        可以适应小屏幕
        设置宽度并且居中........................................mid....................................................................................mid
    </div>
</body>
</html>